<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
    <!--workactive 不能写成 workactive  否则会报控制器不存在-->
        <li><a href="{:url('Work/workactiveIndex')}">作业活动</a></li>
		<li  class="active"><a href="{:url('Work/workactiveAdd')}">添加作业活动</a></li></li>
    </ul>
    <!-- js-ajax-form-->
    <form class="form-horizontal margin-top-20" action="{:url('Work/workactiveAddPost')}" method="post">
        <div class="form-group">
            <label for="input-workActiveName" class="col-sm-2 control-label"><span class="form-required">*</span>作业活动名称</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-workActiveName" name="workActiveName">
            </div>
        </div>
        <div class="form-group">
            <label for="input-workInfo" class="col-sm-2 control-label"><span class="form-required">*</span>作业活动内容</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-workInfo" name="workInfo">
            </div>
        </div>
        <div class="form-group">
            <label for="input-parent_id" class="col-sm-2 control-label"><span class="form-required">*</span>部门名称</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="depart_id" id="input-depart_id" 
                     onchange="searchStation()">
                    <option value="0">作为一级菜单</option>{$select_category}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-stationID" class="col-sm-2 control-label"><span class="form-required">*</span>岗位名称</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="stationID" id="select_station"
                           >
                </select>
            </div>
        </div>

        <div class="form-group">
            <label for="input-workFrequency" class="col-sm-2 control-label"><span class="form-required">*</span>活动频率</label>
            <div class="col-md-6 col-sm-10">
                 <select class="form-control" name="workFrequency">
                    <option value="定期">定期</option>
                    <option value="频繁进行">频繁进行</option>
                    <option value="特定时间进行">特定时间进行</option>
                </select>
            </div>
        </div>
		<div class="form-group">
            <label for="input-memos" class="col-sm-2 control-label"><span class="form-required">*</span>备注</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-memos" name="memos">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
        /*组织机构下拉框选择事件*/
        function searchStation() {
          //获取组织机构select 对象
           var selectDepartment = document.getElementById('input-depart_id');  
           //拿到选中项的索引：
           var index=selectDepartment.selectedIndex;
           //拿到选中项options的value：
           var departmentValue = selectDepartment.options[index].value;
          
           //拿到选中项options的text：
           //var departmentStr = (selectDepartment.options[index].text);
           var departmentText = selectDepartment.options[index].text;
           
           $.ajax({
                url:"/index.php/admin/user/ajaxStation",
                data:{stationStr:departmentValue},
                type:"get",
                dataType:"json",
                success: function(data){
                    $("#select_station").find("option").remove();
                    // $("#select_station").append("<option value=''>请选择</option>");
                    //动态给select 赋值
                    for(var i=0;i<data.length;i++){
                       $("#select_station").append("<option id = '"+ data[i]["stationID"]+"' value='"+ data[i]["stationID"]+"'>"+ data[i]["stationName"]+"</option>");
                    } 
                }
            });
        }
    </script>
</body>
</html>